﻿package mortal.game.view.nationalDayAct
{
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class nationalDayActBasePanel extends GSprite
    {
        protected var _topBg:GImageBitmap;
        protected var _topDescTxt1:GImageBitmap;
        protected var _countDownBg:GImageBitmap;
        protected var _countDownTxt:GImageBitmap;
        protected var _stateTxt:GTextFiled;
        protected var _dayTxt:BitmapNumberText;
        protected var _hourTxt:BitmapNumberText;
        protected var _minTxt:BitmapNumberText;
        protected var _secView:SecTimerView;
        protected var _actTimeTitleTxt:GTextFiled;
        protected var _actTimeTxt:GTextFiled;
        protected var _actDescTitleTxt:GTextFiled;
        protected var _actDescTxt:GTextFiled;
        protected var _actIndex:int;

        public function nationalDayActBasePanel(param1:int)
        {
            this._actIndex = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(0, 0, 701, 551, this));
            this._topBg = UIFactory.gImageBitmap(ImagesConst.nationalDayActTopBg, 7, 4, this);
            this._topDescTxt1 = UIFactory.gImageBitmap(ImagesConst.nationalDayActFirstTxt, 40, 10, this);
            this._countDownBg = UIFactory.gImageBitmap(ImagesConst.nationalDayActCountDownBg, 6, 122, this);
            this._countDownTxt = UIFactory.gImageBitmap(ImagesConst.nationalDayActCountDownTxt, 65, 130, this);
            this._stateTxt = UIFactory.gTextField("", 100 - 31, 200 - 72, 220, 40, this, GlobalStyle.textFormatBai.setSize(16));
            this._dayTxt = UIFactory.bitmapNumberText(152 + 80 - 39, 143 - 60 + 44, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._dayTxt.text = "00";
            this._hourTxt = UIFactory.bitmapNumberText(205 + 80 - 25, 143 - 60 + 44, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hourTxt.text = "00";
            this._minTxt = UIFactory.bitmapNumberText(276 + 80 - 19, 143 - 60 + 44, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._minTxt.text = "00";
            this._actTimeTitleTxt = UIFactory.gTextField(Language.getString(90449), 7, 161, 220, 40, this, GlobalStyle.textFormatHuang.setSize(16));
            this._actTimeTxt = UIFactory.gTextField(nationalDayActUtil.getActDateTimeLabel(this._actIndex), 97, 161, 300, 40, this, GlobalStyle.textFormatBai.setSize(16));
            this._actDescTitleTxt = UIFactory.gTextField(Language.getString(90450), 7, 188, 220, 40, this, GlobalStyle.textFormatHuang.setSize(16));
            this._actDescTxt = UIFactory.gTextField("", 97 - 58, 188 + 35, 600, 400, this, GlobalStyle.textFormatBai.setSize(16).setLeading(8));
            this._secView = new SecTimerView();
            this._secView.addEventListener(EventName.SecViewTimeChange, this.onTimeChangeHd);
            this.setTimeCountDown();
            this.setDescTxt();
            return;
        }// end function

        protected function setDescTxt() : void
        {
            return;
        }// end function

        protected function setTimeCountDown() : void
        {
            var _loc_1:* = this.getLeftTime();
            this._secView.stop();
            if (_loc_1 < 0)
            {
                _loc_1 = 0;
            }
            this._secView.setLeftTime(_loc_1);
            return;
        }// end function

        protected function getLeftTime() : Number
        {
            return nationalDayActUtil.getLeftTime(this._actIndex) / 1000;
        }// end function

        protected function clearTimer() : void
        {
            if (this._secView)
            {
                this._secView.stop();
                this._secView.removeEventListener(EventName.SecViewTimeChange, this.onTimeChangeHd);
                this._secView.dispose();
                this._secView = null;
            }
            return;
        }// end function

        protected function setActNotStart() : void
        {
            this._stateTxt.visible = true;
            this._stateTxt.text = Language.getString(90451);
            this._countDownTxt.visible = false;
            this._dayTxt.visible = false;
            this._hourTxt.visible = false;
            this._minTxt.visible = false;
            return;
        }// end function

        protected function setActRun() : void
        {
            this._stateTxt.visible = false;
            this._countDownTxt.visible = true;
            this._dayTxt.visible = true;
            this._hourTxt.visible = true;
            this._minTxt.visible = true;
            return;
        }// end function

        protected function setActEnd() : void
        {
            this._stateTxt.visible = true;
            this._stateTxt.text = Language.getString(90452);
            this._countDownTxt.visible = false;
            this._dayTxt.visible = false;
            this._hourTxt.visible = false;
            this._minTxt.visible = false;
            return;
        }// end function

        protected function onTimeChangeHd(event:DataEvent) : void
        {
            var _loc_2:* = this.getLeftTime();
            if (_loc_2 < 0)
            {
                this.clearTimer();
                this.setActNotStart();
                return;
            }
            if (_loc_2 == 0)
            {
                this.clearTimer();
                this.setActEnd();
                return;
            }
            this.setActRun();
            if (this._secView == null)
            {
                return;
            }
            if (this._secView.secTimerViewData == null)
            {
                this._secView.stop();
                return;
            }
            var _loc_3:* = this._secView.secTimerViewData.dd();
            var _loc_4:* = this._secView.secTimerViewData.hh();
            var _loc_5:* = this._secView.secTimerViewData.mm();
            if (_loc_3.length == 2 && _loc_3 == "0")
            {
                _loc_3 = _loc_3.substring(1);
            }
            this._dayTxt.text = "" + _loc_3;
            this._hourTxt.text = "" + _loc_4;
            this._minTxt.text = "" + _loc_5;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._topBg.dispose(param1);
            this._topDescTxt1.dispose(param1);
            this._stateTxt.dispose(param1);
            this._countDownBg.dispose(param1);
            this._countDownTxt.dispose(param1);
            this._dayTxt.dispose(param1);
            this._hourTxt.dispose(param1);
            this._minTxt.dispose(param1);
            this._actTimeTitleTxt.dispose(param1);
            this._actTimeTxt.dispose(param1);
            this._actDescTitleTxt.dispose(param1);
            this._actDescTxt.dispose(param1);
            this._topBg = null;
            this._topDescTxt1 = null;
            this._stateTxt = null;
            this._countDownBg = null;
            this._countDownTxt = null;
            this._dayTxt = null;
            this._hourTxt = null;
            this._minTxt = null;
            this._actTimeTitleTxt = null;
            this._actTimeTxt = null;
            this._actDescTitleTxt = null;
            this._actDescTxt = null;
            this.clearTimer();
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
